<?php

namespace App\Http\Middleware;

use App\Models\Iptable;
use Closure;
use Illuminate\Support\Facades\Redis;

class UserIpAuth
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $ips = Redis::get('ips');
        if (is_null($ips) || empty($ips)) {
            $ips = Iptable::select('ip')->get()->toArray();
            if (1){

            }
            return redirect()->away('https://www.baidu.com');
        }
        return $next($request);
    }
}
